/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package conversorhl7;

import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.parsers.SAXParser;

/**
 *
 * @author geraldo
 */
public class Conversor {
    
    
    
    
    
    
    
    public void gravarExame(Exame exame){
      
        Pacient<String> Nome;
        
       
        
    String qee = new String();
        
        try{
            XMLEncoder encoder = null;
            
            try{
                encoder = new XMLEncoder(new FileOutputStream("exame.xml"));
                encoder.writeObject(exame);
            
            }finally{
                if (encoder !=null) 
                    encoder.close();
            }
        
        }catch(IOException e){
            System.out.println(e.getMessage());
            }
    
    }
    
    public Exame recuperarExame() throws FileNotFoundException{
        Exame exames = new Exame();
        
        try{
            XMLDecoder decoder = null;
            try{
                decoder = new XMLDecoder(new FileInputStream("exame.xml"));
                
                exames = (Exame) decoder.readObject();
                System.out.println("exames lidos: ");
            
            }finally{
                if (decoder!=null){
                    decoder.close();
                }
            
            }
            
        }catch(IOException e){
            System.out.println(e.getMessage());
        
        }
        
        return exames;
    }

    
    
    
}
